<?php
	require_once('../includes/config.php');
	$action = $_REQUEST['act'];
	$newsid = $_POST['id'];
	$newstitle = $_POST['title'];
	$newsdetail = $_POST['detail'];
	$newsimg = $_POST['newsimg'];	
	$timenow = date("Y-m-d H:i:s");
	if($action == "add")
	{

		$sql_insert = "INSERT INTO tbl_news ( news_title, news_detail, news_img, news_date_added) VALUES ( '$newstitle', '$newsdetail', '$newsimg', '$timenow')";
		mysql_query($sql_insert) or die("can not insert into database");
		echo 1;
		exit;
	}
	elseif($action == "edit")
	{
		mysql_query("UPDATE tbl_news SET news_title = '$newstitle', news_detail = '$newsdetail', news_img = '$newsimg', news_lasted_update = '$timenow' WHERE id = '$newsid'") or die("can not update");
		echo 1;
		exit;
	}
	elseif($_GET['act'] == "del")
	{
		$id = $_REQUEST['id'];
		mysql_query("DELETE FROM tbl_news WHERE id = '$id'");
		echo 1;
		exit;
	}


?>